package com.xujl.app2;

import android.os.Bundle;
import android.os.RemoteException;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.changan.remote.assistant.IAssisantCallback;
import com.changan.remote.assistant.RemoteAssistantManager;

public class MainActivity extends AppCompatActivity  {
    TextView tv;

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = findViewById(R.id.tv);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick (View v) {
                RemoteAssistantManager.getInstance().sendEvent("发送事件2");
            }
        });
        RemoteAssistantManager.getInstance().registerListener(mIMyAidlCallBack);
    }

    private IAssisantCallback.Stub mIMyAidlCallBack = new IAssisantCallback.Stub() {
        @Override
        public void onCallback (final String json) throws RemoteException {
            runOnUiThread(new Runnable() {
                @Override
                public void run () {
                    tv.setText(json);
                }
            });
        }

        @Override
        public int getModuleType () throws RemoteException {
            return 0;
        }

    };

}
